package com.henu.tanhang;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageButton;
import android.widget.ListView;

import com.henu.R;
import com.henu.adapter.CheckallAdapter;
import com.henu.tanhang.entity.Detail;

import java.util.ArrayList;

public class CheakAll extends AppCompatActivity {

    private ListView cheakall;
    private CheckallAdapter adapter;
    private ArrayList<Detail> details = new ArrayList<>();
    private ImageButton aca_return;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cheak_all);

        cheakall = (ListView)findViewById(R.id.checkall);
        adapter = new CheckallAdapter(this);
        cheakall.setAdapter(adapter);

        final Intent intent = getIntent();
        details = (ArrayList<Detail>)intent.getSerializableExtra("detail");

        adapter.addData(details);
        adapter.notifyDataSetChanged();


        aca_return = (ImageButton) findViewById(R.id.aca_return);
        aca_return.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

        cheakall.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

                System.out.println("AAA");
                Intent intent1 = new Intent(CheakAll.this,DetailActivity.class);
                intent1.putExtra("detail",details.get(i));
                Detail detail = details.get(i);
                System.out.println(detail.getCheckname()+"-----"+detail.getPhone());
                startActivity(intent1);
            }
        });
    }
}
